//package com.aos.web;
//
//import com.aos.annotation.SysLogger;
//import com.aos.dto.RespDTO;
//import com.aos.entity.User;
//import com.aos.util.MD5PwdEncoderUtils;
//import com.aos.util.UserUtils;
//import io.swagger.annotations.ApiOperation;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.security.access.prepost.PreAuthorize;
//import org.springframework.web.bind.annotation.*;
//
//@RestController
//@RequestMapping("/user")
//public class UserController {
//
//
//    @ApiOperation(value = "注册", notes = "username和password为必选项")
//    @PostMapping("/registry")
//    @SysLogger("registry")
//    public User createUser(@RequestBody User user){
//        //参数判读省略,判读该用户在数据库是否已经存在
//        if(userService.checkUserExist(user)) return null;
//        //创建salt
//        if(null == user.getSalt()){
//            user.setSalt(UserUtils.UUID());
//        }
//        String entryPassword= MD5PwdEncoderUtils.MD5CryptPassword(user.getPassword(),user.getSalt());
//        user.setPassword(entryPassword);
//        return userService.createUser(user);
//    }
//
//    @ApiOperation(value = "登录", notes = "username和password为必选项")
//    @PostMapping("/login")
//    @SysLogger("login")
//    public RespDTO login(@RequestParam String username , @RequestParam String password){
//        if(null == username || null == password){
//            RespDTO dto = new RespDTO();
//            dto.error = "用户名和密码均不能为空，请检查！";
//            return dto;
//        }
//      return   userService.login(username,password);
//    }
//
//    @ApiOperation(value = "根据用户名获取用户", notes = "根据用户名获取用户")
//    @PostMapping("/{username}")
//    @PreAuthorize("hasRole('ADMIN')")
//    @SysLogger("getUserInfo")
//   // @PreAuthorize("hasAnyAuthority('ROLE_USER')")
//    public RespDTO getUserInfo(@PathVariable("username") String username){
//        //参数判读省略
//        User user=  userService.getUserInfo(username);
//        return RespDTO.onSuc(user);
//    }
//
////    @Autowired
////    private AmqpTemplate rabbitTemplate;
////    @GetMapping("/test")
////    public void test(){
////        rabbitTemplate.convertAndSend(RabbitConfig.queueName, "Hello from RabbitMQ!");
////    }
//
//    @Value("${foo}")
//    String foo;
//    @GetMapping("/test")
//    public String test(){
//        return foo;
//    }
//}
